<?php


namespace app\api\model;


class User extends BaseModel {

    /**
     * 拥有外键的一方定义一对一的关系用belongsTo
     * 没有外键的表中使用hasOne
     *
    */

    //获取该用户的地址信息关联
    public function address(){
        return $this->hasOne('UserAddress','user_id','id');
    }

    public static function getByOpenId($openid){
        $user = self::where('openid','=',$openid)->find();
        return $user;
    }
}







